Ext.ns('AIR2.Drawer');
/***************
 * AIR2 Drawer Footerbar Component
 *
 * An Ext.Toolbar for use as the bottom toolbar of an AIR2 drawer.
 *
 * @class AIR2.Drawer.Footerbar
 * @extends Ext.Toolbar
 * @xtype air2drawerfbar
 * @cfg {Function} startNewFn
 *   Function that toolbar should call to create a new Bin.
 * @cfg {Function} endNewFn
 *   Function that toolbar should call when done creating a new Bin
 *
 */
AIR2.Drawer.Footerbar = function(config) {
    config = config || {};
    config.defaults = {
        xtype: 'tbtext',
        handler: this.handleClick
    };
    config.items = ['->', {
        xtype: 'air2button',
        air2type: 'NEW',
        air2size: 'MEDIUM',
        text: 'Create',
        cls: 'air2-drawer-create',
        handler: function() {config.startNewFn()}
    },{
        xtype: 'air2button',
        air2type: 'SAVE',
        air2size: 'MEDIUM',
        text: 'Save',
        handler: function() {config.endNewFn(true)},
        hidden: true
    },{
        xtype: 'air2button',
        air2type: 'CANCEL',
        air2size: 'MEDIUM',
        text: 'Cancel',
        handler: function() {config.endNewFn(false)},
        hidden: true
    }];

    // call parent constructor
    AIR2.Drawer.Footerbar.superclass.constructor.call(this, config);
}
Ext.extend(AIR2.Drawer.Footerbar, Ext.Toolbar, {
    cls: 'air2-bin-fbar',
    setNewMode: function(newMode) {
        if (newMode) {
            this.get(1).hide();
            this.get(2).show();
            this.get(3).show();
        }
        else {
            this.get(1).show();
            this.get(2).hide();
            this.get(3).hide();
        }
    }
});
Ext.reg('air2drawerfbar', AIR2.Drawer.Footerbar);